
<div class="easyui-layout" data-options="fit:true">
	 <div data-options="region:'north',border:false" style="height:100px;overflow: hidden;background:#F4F4F4">
       	<div id="startOrderScan_toolbar" style="border-bottom:1px solid #ddd;height: auto">
			<@eu.linkbutton showName="新增" shiro="trans:startOrderScan:add" iconCls="icon-add" onclick="addStartOrderScan()"/>
			<@eu.linkbutton showName="更新或保存" shiro="trans:startOrderScan:saveOrUpdate" iconCls="icon-save" onclick="saveStartOrderScan()"/>
		</div>
	    <form id="startOrderScanForm" action="transOrderScan.do?sureStartScan">
	    	<table>
	    		<tr>
	    			<td class="tbLabel" rowspan="2">运单号:</td>
	    			<td rowspan="2"><input id="startOrderNo" style="height: 40px;width:200px;" name="orderNo" class="easyui-validatebox textbox" onchange="loadStartOrderInfo()" /></td>
	    			<td class="tbLabel">收件人:</td>
	    			<td><input id="tstest" type="text" name="receiver" class="easyui-validatebox textbox" readonly="readonly"/></td>
	    			<td class="tbLabel">收件人电话:</td>
	    			<td><input type="text" name="receivePhone" class="easyui-validatebox textbox" readonly="readonly"/></td>
	    			<td class="tbLabel">目的站:</td>
	    			<td>
	    				<@eu.comboBox disabled="true" url="transWebSite.do?loadWebsiteCombox&value=${(transAccountItem.websiteId)!}" name="endWebsiteId" required="true" />
	    			</td>
	    		</tr>
	    		<tr>
	    			<td>寄件人:</td>
	    			<td><input type="text" name="sender" class="easyui-validatebox textbox" readonly="readonly"></input></td>
	    			<td>寄件电话:</td>
	    			<td><input type="text" name="sendPhone" class="easyui-validatebox textbox" readonly="readonly"></input></td>
	    			<td>当前网点:</td>
	    			<td>
	    				<input id="startScanWebsiteBegin" type="hidden" name="startWebsiteId" value="${(personWebsiteId)!}"/>
	    				<@eu.comboBox id="startScanWebsite" disabled="true" url="transWebSite.do?loadWebsiteCombox&value=${(personWebsiteId)!}" name="currentWebsiteId" required="true" />
	    			</td>
	    		</tr>
	    	</table>
	    </form>
     </div>
	<div data-options="region:'center',border:false,title:'扫描清单'">
		<@eu.datagrid id="startOrderScan_list" idField="id"
			 url="transOrderScan.do?loadStartScanList&scanType=1&creator=${(user.loginName)!}" rownumbers="true" toolbar="#startOrderScanListSearch"
			 item="com.xdtech.trans.vo.OrderStartScanItem"/>
		<div id="startOrderScanListSearch">
<!-- 			<div style="margin-bottom:5px;padding-left:5px;margin-top: 5px;"> -->
<!-- 				<form id="startOrderScanSearchForm"> -->
<!-- 					<table> -->
<!-- 						<tr> -->
<!-- 							<td>运单号：</td> -->
<!-- 							<td> -->
<!-- 								<input type="text" name="orderNo" > -->
<!-- 							</td> -->
<!-- 							<td> -->
<!-- 								<@eu.linkbutton showName="查询" iconCls="icon-search" onclick="startOrderScanSearch()"/> -->
<!-- 	 					 		<@eu.linkbutton showName="清空" iconCls="icon-clear" onclick="clearStartOrderScanSearch()"/> -->
<!--  					 		</td> -->
<!-- 						</tr> -->
<!-- 					</table> -->
<!-- 				</form> -->
<!-- 			</div> -->
			<div id="startOrderScanToolbar" style="height: auto">
				<@eu.linkbutton showName="删除" shiro="trans:transOrderScan:delete" iconCls="icon-remove" onclick="deleteStartOrderScan()"/>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
	$('#startOrderNo').onkeydown = function(e) {
		var event = e || window.event;
		var code = event.keyCode || event.which || event.charCode;
		if (code == 13) {
			loadStartOrderInfo();
		}
	}
	
	function addStartOrderScan() {
		resetScanInfo('startOrderScanForm','startScanWebsite','${(personWebsiteId)!}');
	}
	
	function loadStartOrderInfo() {
// 		printLog($('#startOrderNo').val());
// 		printLog($('#startOrderNo').textbox('getValue'));
		var orderNo = $('#startOrderNo').val();
		$.post('transOrderScan.do?loadTransOrderLastestScanInfo',{orderNo:orderNo},function(result){
	       	   printLog(result);
	           if (result.success){
	           	 $("#startOrderScanForm").form('load', result.obj);
	           	 if('${(START_SCAN_AUTO_SAVE)!}'=='Y') {
	           		 window.setTimeout("saveStartOrderScan()" , 500);
	           	 }
	           	
	           } else {
	        	   showMsg(result.msg,3000);
	           }
	        },'json');
	}
	
	function saveStartOrderScan() {
		var validate = $('#startOrderScanForm').form("validate");
		if(validate) {
			var actionurl = $('#startOrderScanForm').attr('action');//提交路径
			var formData = new Object();

			var fields = $('#startOrderScanForm').serializeArray(); //自动序列化表单元素为JSON对象  

			$.each(fields, function(i, field) {
				printLog(field.name + "=" + field.value);
				formData[field.name] = field.value;
			});
// 			printLog(formData);
			jmaxAjax(actionurl,formData,function(rs) {
				resetScanInfo('startOrderScanForm','startScanWebsite','${(personWebsiteId)!}');
				$('#startScanWebsiteBegin').val('${(personWebsiteId)!}');
				reloadStartOrderScan();
			});
		}
	}
	//表格查询  
	function reloadStartOrderScan() {
		var params = startOrderScan_list.datagrid('options').queryParams; //先取得 datagrid 的查询参数  
		printLog(params);
		startOrderScan_list.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		startOrderScan_list.datagrid('unselectAll');
		startOrderScan_list.datagrid('uncheckAll');
	}
	
	function deleteStartOrderScan() {
		var rows = startOrderScan_list.datagrid('getChecked');
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('transOrderScan.do?deleteTransOrderScanItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadStartOrderScan();    
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
	
	$("#startOrderNo").focus();
</script>